package com.college.eduService.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.college.eduService.client.VodClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.college.eduService.entity.EduVideo;
import com.college.eduService.mapper.EduVideoMapper;
import com.college.eduService.service.EduVideoService;
@Service
public class EduVideoServiceImpl extends ServiceImpl<EduVideoMapper, EduVideo> implements EduVideoService{
    @Autowired
    VodClient vodClient;
    //根据课程id删除小节
    @Override
    public void removeVideoByCourseId(String id) {
        QueryWrapper<EduVideo> wrapper=new QueryWrapper<>();
        wrapper.eq("course_id",id);
        List<EduVideo> videos=this.list(wrapper);
        for(EduVideo video:videos){
            vodClient.removeAlyVideo(video.getVideoSourceId());
        }
        baseMapper.delete(wrapper);
    }
}
